package com.ruoyi.inspection.config;

import com.ruoyi.common.utils.StringUtils;

import java.util.Arrays;

public enum JobBillTypeEnum {
    DONGHUO_JOB_BILL("03", "动火作业"),
    GAOCHU_JOB_BILL("21", "高处作业"),
    DIAOZHUANG_JOB_BILL("63", "吊装作业"),
    HOT_WORK_SECURITY_JOB_BILL_3("01", "特级（8H）"),
    HOT_WORK_SECURITY_JOB_BILL_1("02", "一级（8H）"),
    HOT_WORK_SECURITY_JOB_BILL_2("03", "二级（72H）"),
    TEMPORARY_ELECTRIC_SECURITY_JOB_BILL("10", "临时用电作业"),
    HIGH_SECURITY_JOB_BILL_1("21", "Ⅰ级2m≤h≤5m"),
    HIGH_SECURITY_JOB_BILL_2("22", "Ⅱ级5m＜h≤15m"),
    HIGH_SECURITY_JOB_BILL_3("23", "Ⅲ级l5m＜h≤30m"),
    HIGH_SECURITY_JOB_BILL_4("24", "Ⅳ级h＞30m"),
    GROUNDBREAKING_SECURITY_JOB_BILL("30", "动土作业"),
    OPEN_CIRCUIT_SECURITY_JOB_BILL("40", "断路作业"),
    BLIND_PLATE_SECURITY_JOB_BILL("50", "盲板抽堵作业"),
    HOISTING_SECURITY_JOB_BILL_1("61", "一级m >100t"),
    HOISTING_SECURITY_JOB_BILL_2("62", "二级40t≦m≦100t"),
    HOISTING_SECURITY_JOB_BILL_3("63", "三级m<40t"),
    LIMITED_SECURITY_JOB_BILL("70", "受限空间作业"),
    GUAN_ZHUANYI_JOB_BILL("A0", "倒罐作业"),
    GUAN_QINGXI_JOB_BILL("B0", "清罐作业"),
    GUAN_QIESHUI_JOB_BILL("C0", "切水作业");



    private String code;
    private String desc;

    JobBillTypeEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static String valueOfCode(String desc) {
        if (StringUtils.isEmpty(desc)) {
            return "00";
        }

        JobBillTypeEnum jobBillTypeEnum = Arrays.stream(values()).filter(status -> status.getDesc().equals(desc)).findFirst().orElse(null);

        return jobBillTypeEnum != null ? jobBillTypeEnum.getCode() : "00";
    }

    public static String valueOfCode2(String descPrefix) {
        if (StringUtils.isEmpty(descPrefix)) {
            return "00";
        }

        JobBillTypeEnum jobBillTypeEnum = Arrays.stream(values()).filter(status -> status.getDesc().startsWith(descPrefix)).findFirst().orElse(null);

        return jobBillTypeEnum != null ? jobBillTypeEnum.getCode() : "00";
    }

}